package com.wuzy.core.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.wuzy.core.pojo.SysRole;
import com.wuzy.core.service.ISysRoleService;

@Controller
@RequestMapping("/core/sysrole/")
public class SysRoleController {
	@Autowired
	private ISysRoleService sysRoleService;
	@RequestMapping("toAddRole")
	public ModelAndView toAddRole(){
		return new ModelAndView("addRole");
	}
	@RequestMapping("addrole")
	public ModelAndView addrole(SysRole sysRole){
		sysRole.setId("ww"+(int)(Math.random()*(10000)));
		sysRoleService.add(sysRole);
		ModelAndView mv=new ModelAndView("redirect:/core/sysrole/listrole");
		return mv;
	}
	@RequestMapping("listrole")
	public ModelAndView listrole(){
		List<SysRole> sysRoleList=sysRoleService.getAll();
		return new ModelAndView("listRole").addObject("sysRoleList", sysRoleList);
	}

}
